<script setup lang="ts">
import { handleMessage } from '@/utils/globalEvent';

// 多少秒后执行
const delay = (Number(import.meta.env.VITE_DELAY) / 1000) * 2;
// 立即执行
const immediate = 'immediate';
// 防抖
const handleThrottle = () => {
	handleMessage('我是节流按钮触发的事件');
};
// 立即执行
const immediateThrottle = () => {
	handleMessage('我是节流立即执行按钮触发的事件');
};
</script>

<template>
	<div class="throttle">
		<el-button v-throttle="handleThrottle">节流按钮({{ delay }}秒后执行)</el-button>
		<el-button v-throttle:[immediate]="immediateThrottle">节流立即执行按钮</el-button>
	</div>
</template>

<style lang="less" scoped>
@import url('./index.less');
</style>
